<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>搜索引擎</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no"/>
    <META name="apple-mobile-web-app-capable" content="yes">
    <META name="layoutmode" content="standard">
    <META name="apple-mobile-web-app-status-bar-style" content="black">
    <META name="renderer" content="webkit">
    <META name="wap-font-scale" content="no">
    <META name="format-detection" content="telephone=no">
    <META http-equiv="Pragma" content="no-cache">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/res/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/res/css/index.css">
    <script src="${pageContext.request.contextPath}/res/bootstrap/js/jquery-1.12.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/res/bootstrap/js/bootstrap.min.js"></script>

</head>
<body class="b_div">
<div class="c_div">
    <div class="search_div">
        <input type="text" class="form-control " id="keyWord" name="keyWord" placeholder="请输入需要搜索的内容"
               style="width: 60%;float: left"/>
        <button onclick="search()" type="button" class="btn btn-primary"
                style="float: left;margin-left: 10px;width: 10%;">搜&nbsp;&nbsp;索
        </button>
        <button onclick="index()" type="button" class="btn btn-primary"
                style="float: left;margin-left: 10px;width: 10%;">索&nbsp;&nbsp;引
        </button>
    </div>

    <div class="search_con" id="searchResult">


    </div>


</div>


<script type="text/javascript">

    var search = function () {
        var keyWord = $('#keyWord').val();
        $.get("${pageContext.request.contextPath}/file/search/" + keyWord,function(html){
            $('#searchResult').html(html);
        });
        <%--$.ajax({--%>
            <%--url: "${pageContext.request.contextPath}/file/search/" + keyWord,--%>
            <%--type: "GET",--%>
            <%--dataType: "json",--%>
            <%--async: false,--%>
            <%--success: function (html) {--%>
                <%--console.log(html);--%>

                 <%--$('#searchResult').html(html);--%>

            <%--},--%>
            <%--error: function (html) {--%>
                <%--console.log(html);--%>
                <%--alert("连接失败,请稍候再试!");--%>
            <%--}--%>

        <%--});--%>
    }
    var index = function () {
        $.get("${pageContext.request.contextPath}/file/createIndex.json",function (data) {
            alert(data.msg);
        });
    }

</script>
</body>
</html>